#include "mf_iwdt.h"

/**
 * @brief  IWDT Initialization function
 * @param  MF_IWDT_PERIOD
 * @retval None
 */
void mf_iwdt_init(MF_IWDT_PERIOD iwdt_period)
{
    FL_IWDT_InitTypeDef IWDT_InitStruct;
    switch (iwdt_period)
    {
    case MF_IWDT_TIM_125MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_125MS;
        break;
    case MF_IWDT_TIM_250MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_250MS;
        break;
    case MF_IWDT_TIM_500MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_500MS;
        break;
    case MF_IWDT_TIM_1000MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_1000MS;
        break;
    case MF_IWDT_TIM_2000MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_2000MS;
        break;
    case MF_IWDT_TIM_4000MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_4000MS;
        break;
    case MF_IWDT_TIM_8000MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_8000MS;
        break;
    case MF_IWDT_TIM_16000MS:
        IWDT_InitStruct.overflowPeriod = FL_IWDT_PERIOD_16000MS;
        break;
    default:
        break;
    }
    IWDT_InitStruct.iwdtWindows = 0;

    FL_IWDT_Init(MF_IWDT_BASE, &IWDT_InitStruct);
}

/**
 * @brief  IWDT mf_iwdt_refresh function
 * @param  void
 * @retval None
 */
void mf_iwdt_refresh(void)
{
    FL_IWDT_ReloadCounter(IWDT);
}